package test.demo;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import cop.publ.Ctx;
import cop.publ.LayeredClass;

@LayeredClass
public class PersonPerformance {

	  
	static{BasicConfigurator.configure();}
	private static final Logger logger = Logger.getLogger(PersonPerformance.class);
	static{ logger.setLevel(Level.OFF); } 
	
	private static int count = Performance.DEPTH;


	public String printALayer(){
		logger.debug("print layer A");
		printBLayer();
		Performance.fact();
		logger.debug("print layer A");
		return "layerA method";
	}

	public String printBLayer(){
		logger.debug("print layer B");
		printCLayer();
		Performance.fact();
		logger.debug("print layer B");
		return "layerB method";
	}

	public String printCLayer(){
		logger.debug("print layer C");
		print();
		Performance.fact();
		logger.debug("print layer C");
		return "layerC method";
	}
	
	public String print(){
		logger.debug("print base method");
		if (count > 0) {
			count--;
			Performance.fact();
			printALayer();
		}
		return "print base method";
	}
	
	public String print2(int a){
		System.out.println("print2 base method: " + new Integer(a).toString());
		return "print base method";
	}
	
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		PersonPerformance p = new PersonPerformance();
		
		p.printALayer();
		
		p.print();
		count = Performance.DEPTH;
		int tmp1 = count;
		
		int loop = Performance.LOOP;
		int tmp2 = loop;
		
		long time1 = System.currentTimeMillis();
		while(loop > 0 ){
			p.printALayer();
			loop--;
		}
		
		long time2 = System.currentTimeMillis();
		
		int tmp3 = Performance.FACT;
		
		System.out.format("%d %d %d : %d%n",tmp1, tmp2, tmp3, time2-time1);	
		
	}
}





